Gameboy 98
----------

Usage
-----
Cursor keys for directions, Z/X for buttons A/B and the Enter key for Start and Space bar for select.

Legal Stuff
-----------

 This is a Nintendo Gameboy emulator. This software is in no way endorsed by Nintendo, or even if they knew about it would be endorsed by them.

About this program
------------------
 I started writing a Gameboy emulator many years ago, although at that time, I never got very far with it. During the first few weeks of October 1998, I found various docs on the gameboy on the net, and so resurrected this project. Well actually I started from scratch again. Mainly it was just a small project to exercise my programming knowledge, and in that it's succeeded. The whole program is written using Win32, no MFC, or any other APIs. Not that it's a major achievement, it was just something to do. Now I get a chance to share the program with the rest of the world.
 It isn't a full emulation of the gameboy, nor wholly accurate. In time though, I hope it will get better. I intend to take suggestions to improve the emulation and the user interface.

Instructions
------------
 As of this first release, use the cursor keys for movement, RETURN is the start button, SPACE is select, and X,Z are buttons A,B. Menu options should be self explanatory, ROM files should be contained in the same directory as the executeable program.

Technical
---------
 What is emulated is the gameboy processor, the screen, Vertical Blanking interrupt, DMA, and the LYC interrupt.
 What is not emulated is sound pitch, serial transfer.

Future Enhancements
-------------------
Faster, faster, faster and faster....
Better Sound Emulation
Sound Setup Dialog
LCD Setup dialog (+option for emulating LCD ghosting)
More complete Z80 Emulation.
Debugger.
Tidier MBC1,MBC2,MBC3 emulation.
Game Genie codes/codefinder.
SGB Emulation.
CGB Emulation.
Modem/Internet Play.

Stuff Done
----------
I took some time out of releasing versions so I could concentrate more on the programming. Now I've fixed a few things that I was just plain emulating wrongly. CPU flags are totally broken still, this'll take a while to fix. I'm not quite sure how interrupts work, but I think I got most of them sorted. The noise channel in the sound is confusing me as to how to get it right, so it's disabled. New things in this version are, game saves are in and working. No matter which speed your processor, it should run at the correct gameboy speed (screen updates just get less often). Redid totally how I did the LCD emulation and added the blurring effect that LCD screens have. There is also a palette editor, just in case you don't like my colors. The debug message viewer displays the framerate, it's also been tidied up a bit.

Interrupts - V0.04v Fixed the interrupt handling code, added TIMER interrupt. Now more images seem to work.  Also fixed RETI.

Sound - As of V0.04 BETA 1t, volume envelopes are in. A few bug fixes.

Sound - As of V0.04, I now use Direct Sound.

Sound - As of V0.02, sound is in and hardwired to mono 22khz replay speed. I've found out after testing it doesn't work on all systems. I will fix this.

Ability to specify image to load upon execution (For use in say a development environment for testing code). Now you can specify on the command line the path and name of the image to load. Or you can set the file association in explorer.

What's New
----------
V0.05c
 Added CGB Emulation.

V0.05 Release
 Fixed several instructions, push, pop, call, ret were actually broken. Also fixed (E8) ADD SP,*. That gets some gbdk examples to nearly work correctly ;). Soon will come the day when gbdk compiled programs will work on my emu, then I can start writing a few programs myself..
V0.05 Private Beta 2
 Added screenshot function. Rewrote cpu emulation engine again. Added more MBC support. Also did some preliminary work on a debugger which isn't functional yet. Redid layering on the gfx engine, now sprite/background/window layers should display correctly.

V0.05 Private Beta 1
 Fixed speed issues when running on a pentium 400 it should play at the real Gameboy speed. Added LCD blur function, game saves are in now too. TIMA emulation was buggy, that's now fixed. Found I was emulating the CPU flags wrongly, that whole CPU emulation needs to be recoded, I've got most of that done now but I'm just trying to tidy up the code so I know what's supposed to go where. Oh, and there's a palette editor in there too.

V0.04 BETA 2
 Did more rework on the interrupts, color palette got changed because I fixed another bug in the frontend. 

V0.04 BETA 1v
 Did some major rework on interrupt generation, and fixed the RETI instruction. Now a lot of things that didn't work, now work a little better. Many things still don't, I ran metroid for a short while and it seems ok, previously it didn't get past the title screen...

V0.04 BETA 1u
 Added a debug message viewer. This displays messages which the emu generates while running a ROM. This is mainly used by me to see what is happening in the emu as a rom is running. One odd side effect of this release is, there's more code but the exe file is smaller.. I managed to strip about 26k of useless stuff out of the emu code. TIMA emulation is in too, this means that in Dr Mario, and Tetris you will get random blocks, rather than the same one. It may affect other games too, but I can't test all of them now can I?
V0.04 BETA 1t
 Removed 2 crash bugs. Pokemon Blue does not work with this emu yet. I'll get to fixing this and more bugs when I have the chance to find out why..
V0.04 BETA 1s
 Playing around with the sound system to make it work properly.
V0.04 BETA 1
 Totally rewrote the sound system, now uses direct sound for sound output. This should sort out ALL the sound crashes and messages people were getting with sound initialization. The old Win32 Multimedia API just ain't capable of doing what I need it to do. Oh, took out the sound options dialog and menu option again.

V0.032
 Redid sound initialization to fix NT crash on ALSound system.

V0.031
 Put in the sound options dialog and menu option.

V0.03
 Better sound initialization. Now asks the soundcard what it can do, and chooses what best fits. Drag & Drop Support, you can drag files onto the emulator window and it will attempt to run them. 

V0.02
 Bugfixes, and slightly faster emulation. Sound if you're lucky. Full MBC1 emulation, partial MBC2,MBC3 emulation. Save games don't work fully.


 Erm, as of this release V0.01, everything you see.

History
-------
7th January 1999 - Hmm, wierd year, I haven't quite gotten used to typing 1999 yet. Anyone remember the TV series 'Space 1999'? Hmm, maybe I'm just far too old. Anyway added CGB emulation just to please all those out there who wanted it. Added a splash screen, and now I'm happy to say I'm now getting a little help from other people, thanks to you all. I will be adding plugin support soon, so anyone will be able to write their own plugins for the gameboy emulator, so if you want better sound, then somebody else can write it.

20th December 1998 - Wow over a month since I updated this section. Lots has changed and I added, rewrote loads of things since the last update. I did say my next set of fixes may take a while, well I didn't lie. Saving screenshots is in, so is a much improved cpu engine (my last one), funkier MBC emulation (but still not perfect), and I've started adding a debugger which doesn't do anything yet!!

14th November 1998 - Fix a frontend bug which broke the colors in the emu, more work on Timer interrupts and trying to find out what causes some roms to just plain die. With the lack of relevant documentation on the GB hardware, this is a difficult task and it may take a while.

14th November 1998 - Debug message box. TIMA emulation. Few other minor fixes & updates.

12th November 1998 - Pokemon Blue definitely doesn't work, I fixed a few bugs which broke the emulator totally. Made a few enhancements nobody will notice. Mainly an anti crash release..

11th November 1998 - During the last few days, I rewrote the LCD handling which was a minor speed improvement (10-15%). Also tried fixing the sound system. Well, I ended up deleting just about all of the old sound system and rewriting it to use DirectSound. This was my first ever DirectSound experience, and I can see why Microsoft did things the way they did, but I hate it. It's far too slow and clunky, but then they wrote windows so what should I expect. Anyway, it's done now, and I'm pretty sure it works for 99% of machines out there unless I missed something?!!! ;-) Over the next few days, I'm going to be improving the sound emulation to the point of perfection I hope. Then I'm gonna work on some of the things that stop the emulator working for some games.

4th November 1998 - V0.03 More preparation for the new assembler Z80 emulation engine going in. Currently everything is in C, so this should speed up emulation by about 20%. After that is in, I'll work on speeding up the LCD refresh, and fixing some window/sprite priority bugs. The new Z80 engine will hopefully cover all opcodes more accurately than my C implementation. The C implementation was hand coded, the assembler is generated. Drag & Drop Support. Should now handle file associations too.

3rd November 1998 - Sped up the LCD redraw functions. Rewrote a lot of the Z80 emulation code as I'm going to move that to assembler, along with a few other time critical functions, such as LCD refresh. More work on the sound, I'm not emulating sound envelopes yet, when I do the sound will be pretty much perfect. The noise channel isn't switched on at all, as I'm not emulating the polynomial noise function yet so it sounds like poo (When it is on). Frequencies should all be spot on, the Pan/Koopa doc says freq = 133333/(2048-xx). This is wrong, but only by a small amount, I could hear the difference in some notes.

25th October 1998 - A lot more ROMs are runnable, I've got Memory emulation down and some sound (the noise channel not currently included). I had bugs in the entire SBC opcodes, which now are working, although it seems I have bugs in some other opcodes though. Most though should work perfectly.

13th October 1998 - Most everything to make some games playable within the emulator, also the load ROM dialog.

Disclaimer
----------
 This software is in no way commercial grade software. Not guarantee is implied in any way. It is also in development, so running it means anything can happen.

Contact Information
-------------------
 I can be reached at adam@programmer.net, if for any reason you need to. I shall be updating this program over time, so if there's something obvious it's probably in the works. If you have particular problems with a specific image, then please feel free to contact me (especially if you know what is exactly wrong). You could always just email me to say hi.